#encoding:utf-8
'''
Created on 2015年7月13日

@author: LWD
'''

"""
循环队列，需要制定队列大小
如果队列满时，再添加元素进队列，覆盖掉最先进入的队列的元素
"""

class CQueue(object):

    def __init__(self, maxsize = 50):
        '''
        @summary: 
        '''
        self.maxsize = maxsize
        # maxsize 默认是50，最小是1 
        if self.maxsize <= 0:
            self.maxsize = 1
        self.index = 0
        self.list = [0] * maxsize
        
    def enqueue(self, element):
        self.list[self.index % self.maxsize] = element
        # 更新index
        self.index += 1
        
    def __contains__(self, obj):
        if obj in self.list:
            return True
        else:
            return False
    
